/**
*      author: Y_Yao
*      created: 2025-03-27 10:17:01
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 7;
string s;
int k;

void solve()
{
    cin >> s;
    int n = s.size();
    s = " " + s;
    cin >> k;
    int left = 1,right = 1;
    int cnt = 0;
    int ans = 0;
    for(;right <= n;right++)
    {
        char in = s[right];
        ans = max(right - left,ans);
        if(in == 'X') continue;
        if(in == '.')
        {
            cnt++;
        }
        while(cnt > k)
        {
            char out = s[left];
            left++;
            if(out == '.') cnt--;
        }
    }
    ans = max(right - left,ans);
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}